import http from './http'

export const adminLogin = (data) => http.post('/admins/login', data)
export const updateAdmin = (adminId, data) => http.put(`/admins/${adminId}`, data)

// 科室管理
export const listDepartments = (params) => http.get('/admins/departments', { params })
export const createDepartment = (data) => http.post('/admins/departments', data)
export const updateDepartment = (id, data) => http.put(`/admins/departments/${id}`, data)
export const deleteDepartment = (id) => http.delete(`/admins/departments/${id}`)

// 职称管理
export const listPositions = (params) => http.get('/admins/positions', { params })
export const createPosition = (data) => http.post('/admins/positions', data)
export const updatePosition = (id, data) => http.put(`/admins/positions/${id}`, data)
export const deletePosition = (id) => http.delete(`/admins/positions/${id}`)

// 指标类别管理
export const listIndicatorCategories = (params) => http.get('/admins/indicator-categories', { params })
export const createIndicatorCategory = (data) => http.post('/admins/indicator-categories', data)
export const updateIndicatorCategory = (id, data) => http.put(`/admins/indicator-categories/${id}`, data)
export const deleteIndicatorCategory = (id) => http.delete(`/admins/indicator-categories/${id}`)

// 检查指标管理
export const listIndicators = (params) => http.get('/admins/indicators', { params })
export const createIndicator = (data) => http.post('/admins/indicators', data)
export const updateIndicator = (id, data) => http.put(`/admins/indicators/${id}`, data)
export const deleteIndicator = (id) => http.delete(`/admins/indicators/${id}`)

// 套餐管理
export const listPackages = (params) => http.get('/admins/packages', { params })
export const createPackage = (data) => http.post('/admins/packages', data)
export const updatePackage = (id, data) => http.put(`/admins/packages/${id}`, data)
export const deletePackage = (id) => http.delete(`/admins/packages/${id}`)
export const listPackageItems = (id) => http.get(`/admins/packages/${id}/items`)
export const addPackageItem = (id, indicatorId) => http.post(`/admins/packages/${id}/items`, null, { params: { indicatorId } })
export const removePackageItem = (itemId) => http.delete(`/admins/packages/items/${itemId}`)

// 用户/医生/管理员列表
export const listAdminUsers = (params) => http.get('/admins/users', { params })
export const listAdminDoctors = (params) => http.get('/admins/doctors', { params })
// 为用户端映射使用，保持与页面导入的函数名一致
export const listDoctors = (params) => http.get('/admins/doctors', { params })
export const createAdminDoctor = (data) => http.post('/admins/doctors', data)
export const listAdminAdmins = (params) => http.get('/admins/admins', { params })

// 订单列表
export const listAdminOrders = (params) => http.get('/admins/orders', { params })

// 医生排班管理
export const createSchedule = (data) => http.post('/admins/schedules', data)
export const updateSchedule = (id, data) => http.put(`/admins/schedules/${id}`, data)
export const deleteSchedule = (id) => http.delete(`/admins/schedules/${id}`)
export const listSchedules = (params) => http.get('/admins/schedules', { params })